﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace FourSquareAPI
{
    public class user
    {
        private string _id;
        private string _firstname;
        private string _lastname;
        private Uri _photo;
        private string _gender;
        private string _phone;
        private string _email;
        private string _twitter;
        private string _facebook;
        private string _friendstatus;
        private checkin _checkin;
        private List<badge> _badges;

        public user(XmlNode Xml)
        {
            XmlNodeList xnl = Xml.ChildNodes;

            foreach (XmlNode xn in xnl)
            {
                switch (xn.Name)
                {
                    case "id":
                        this._id = xn.InnerText;
                        break;
                    case "firstname":
                        this._firstname = xn.InnerText;
                        break;
                    case "lastname":
                        this._lastname = xn.InnerText;
                        break;
                    case "photo":
                        this._photo = new Uri(xn.InnerText);
                        break;
                    case "gender":
                        this._gender = xn.InnerText;
                        break;
                    case "phone":
                        this._phone = xn.InnerText;
                        break;
                    case "email":
                        this._email = xn.InnerText;
                        break;
                    case "twitter":
                        this._twitter = xn.InnerText;
                        break;
                    case "facebook":
                        this._facebook = xn.InnerText;
                        break;
                    case "freindstatus":
                        this._friendstatus = xn.InnerText;
                        break;
                    case "checkin":
                        this._checkin = new checkin(xn);
                        break;
                    case "badges":
                        this._badges = new List<badge>();
                        foreach (XmlNode badge in xn.ChildNodes)
                        {
                            this._badges.Add(new badge(badge));
                        }
                        break;
                }
            }
        }

        public string Id
        {
            get
            {
                return this._id;
            }
        }

        public string Firstname
        {
            get
            {
                return this._firstname;
            }
        }
        public string Lastname
        {
            get
            {
                return this._lastname;
            }
        }

        public Uri Photo
        {
            get
            {
                return this._photo;
            }
        }

        public string Gender
        {
            get
            {
                return this._gender;
            }
        }

        public string Phone
        {
            get
            {
                return this._phone;
            }
        }

        public string Email
        {
            get
            {
                return this._email;
            }
        }

        public string Twitter
        {
            get
            {
                return this._twitter;
            }
        }

        public string Facebook
        {
            get
            {
                return this._facebook;
            }
        }

        public string FriendStatus
        {
            get
            {
                return this._friendstatus;
            }
        }

        public checkin CheckIn
        {
            get
            {
                return this._checkin;
            }
        }

        public List<badge> Badges
        {
            get
            {
                return this._badges;
            }
        }
    }
}
